# 导包
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
# 引入显示等待 WebDriverWait 类
from selenium.webdriver.support.ui import WebDriverWait
# 引入显示等待异常 expected_conditions 库 --用 as 取个别名 EC
from selenium.webdriver.support import expected_conditions as EC

# 实例化浏览器
driver = webdriver.Edge()
# 网址
my_url = 'https://www.leafground.com/select.xhtml'
# 打开网页
driver.get(my_url)
# 窗口最大化
driver.maximize_window()

# 强制等待
# sleep(5)
# ele = driver.find_element(By.ID, 'j_idt87:lang_label')
# print(ele)

# 显示等待--等待元素可见
# element = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.ID, 'j_idt87:lang_label')))
# print(element)

# 隐式等待--设置隐式等待时间为10秒
driver.implicitly_wait(10)

driver.find_element(By.ID, 'j_idt87:city_label')
driver.find_element(By.ID, 'j_idt87:lang_label')

# 等待3秒
sleep(3)
# 关闭实例化浏览器
driver.quit()